#include "Command.hpp"
#include "TcpServer.hpp"

std::string defaulthandle(const std::string &word, InetAddr &addr)
{
    LOG(LogLevel::DEBUG) << "回调到了defaulthandler";
    std::string s = "haha, ";
    s += word;
    return s;
}

void Usage(std::string proc)
{
    std::cerr << "Usage: " << proc << " port" << std::endl;
}

// ./TcpServer port
int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }
    uint port = std::stoi(argv[1]);

    Enable_Console_Log_Strategy();

    Command cmd;
    std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>(port, [&cmd](const std::string &command, InetAddr &addr)
                                                              { return cmd.Execute(command, addr); });    Enable_Console_Log_Strategy();
    tsvr -> Init();
    tsvr ->run();

}